<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="css/login.css" />
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
		<!-- 引入组件 -->
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vant@1.6/lib/vant.min.js"></script>
	</head>
	<body>
		<div id="app">
			<van-row>
				<van-col style="margin-top: 10px;" span="3" offset="21"><van-icon name="cross" size="30px" @click="cross"></van-icon></van-col>
			</van-row>
			<div align="center">
				<img style="margin-top: 30px;" src="img/PingTouGe.jpg" width="120px" height="120px">
			</div>
			<van-cell-group>
				<van-field class="S_login" v-model="phone" label="手机号码" left-icon="phone"></van-field>
				<van-field class="S_login" v-model="pwd" type="password" label="登录密码" left-icon="wap-home"></van-field>
				<van-row class="S_login">
					<van-col offset="18" span="6"><span @click="forget">忘记密码？</span></van-col>
				</van-row>
				<van-row>
					<van-col span="20" offset="2">
						<van-button class="S_login" size="large" type="danger" @click="login">立即登录</van-button>
					</van-col>
				</van-row>

				<div class="S_login" align="center">还没有注册？<span @click="zc">立即注册</span></div>
			</van-cell-group>
		</div>
		<script src="js/ajax.js"></script>
		<script>
			var app = new Vue({
				el: "#app",
				data: {
					phone: "",
					pwd: ""
				},
				methods: {
					zc(){
						plus.webview.show(plus.webview.create("register.html","register"),"slide-in-right");
					},
					forget(){
						plus.webview.show(plus.webview.create("login_forget.html","login_forget"),"slide-in-right");
					},
					cross(){
						plus.webview.close(plus.webview.currentWebview());
					},
					login() {
						_this = this;
						ajax({
							url: "http://dsapi.ysd3g.com/api/login",
							data: {
								account: _this.phone,
								password: _this.pwd
							},
							dataType: "jsonp",
							success: function(res) {
								console.log(res)
								if (!res.Error) {
									localStorage.setItem('Key', res.Key);
									localStorage.setItem('Pwd', _this.pwd);
									localStorage.setItem('userData', JSON.stringify(res.UserData));
									//代码重复 为测试,先看效果
									localStorage.setItem('userData1', JSON.stringify(res));
localStorage.setItem('Phone', res.UserData.Phone);//获取手机号
									plus.webview.getWebviewById("userIndex").reload(true);
									plus.webview.show("userIndex","slide-in-right");
									setTimeout(function(){
										plus.webview.close(plus.webview.currentWebview());
									},500)
								} else {
									alert(res.Msg)
								}
							}
						})
					}
				}
			})
		</script>
	</body>
</html>
